local juedi = fk.CreateSkill {
    name = "gai__juedi",
    tags = { Skill.Compulsory },
  }
  
  Fk:loadTranslationTable{
    ["gai__juedi"] = "绝地",
    [":gai__juedi"] = "锁定技，准备阶段，你选择一项：1.移去「引兵」牌，然后将手牌摸至体力上限；2.令一名体力值不大于你的其他角色将手牌摸至体力上限，"..
    "然后回复1点体力并获得「引兵」牌。",
  
    ["#gai__juedi-choose"] = "绝地：令一名其他角色将手牌摸至体力上限、回复体力并获得「引兵」牌，或点「取消」移去「引兵」牌令自己摸牌",
  
    ["$gai__juedi1"] = "困兽之斗，以全忠义！",
    ["$gai__juedi2"] = "提起武器，最后一搏！"
  }
  
  juedi:addEffect(fk.EventPhaseStart, {
    anim_type = "support",
    can_trigger = function(self, event, target, player, data)
      return target == player and player:hasSkill(juedi.name) and player.phase == Player.Start and
        #player:getPile("$yinbing") > 0
    end,
    on_use = function(self, event, target, player, data)
      local room = player.room
      local targets = table.filter(room:getOtherPlayers(player, false), function(p)
        return p.hp <= player.hp
      end)
      if #targets == 0 then
        room:moveCardTo(player:getPile("$yinbing"), Card.DiscardPile, nil, fk.ReasonPutIntoDiscardPile, juedi.name, nil, true, player)
        local x = player.maxHp - player:getHandcardNum()
        if x > 0 and not player.dead then
          player:drawCards(x, juedi.name)
        end
        return
      end
      local to = room:askToChoosePlayers(player, {
        min_num = 1,
        max_num = 1,
        targets = targets,
        prompt = "#gai__juedi-choose",
        skill_name = juedi.name,
        cancelable = true,
      })
      if #to > 0 then
        to = to[1]
        -- 先让目标角色将手牌摸至体力上限
        local x = to.maxHp - to:getHandcardNum()
        if x > 0 and not to.dead then
          to:drawCards(x, juedi.name)
        end
        -- 然后回复1点体力
        if not to.dead and to:isWounded() then
          room:recover{
            who = to,
            num = 1,
            recoverBy = player,
            skillName = juedi.name,
          }
        end
        -- 最后获得"引兵"牌
        if not to.dead then
          room:moveCardTo(player:getPile("$yinbing"), Card.PlayerHand, to, fk.ReasonJustMove, juedi.name, nil, true, player)
        else
          room:moveCardTo(player:getPile("$yinbing"), Card.DiscardPile, nil, fk.ReasonPutIntoDiscardPile, juedi.name, nil, true, player)
        end
      else
        room:moveCardTo(player:getPile("$yinbing"), Card.DiscardPile, nil, fk.ReasonPutIntoDiscardPile, juedi.name, nil, true, player)
        local x = player.maxHp - player:getHandcardNum()
        if x > 0 and not player.dead then
          player:drawCards(x, juedi.name)
        end
      end
    end,
  })
  
  return juedi